﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using VRTK;

public class Game0 : MonoBehaviour 
{
    #region Others
    public EndTip endTip;
    //脚手架
    public JiaoShouJia jiaoShouJia;

    public CameraPathBezierAnimator cameraPathAni;

    public GameObject curser;

    public AudioClip bgClip;
    public InputController leftController;
    public InputController rightController;
    #endregion

    void Awake()
    {
        PlayerPrefs.SetString("sceneName", "Scene0");
        SoundManager.instance.PlayBGMusic(bgClip);
    }
    void Start()
    {
        jiaoShouJia.OnOver += jiaoshoujia_OnOver;
        curser.GetComponent<DistanceEvent>().OnNearEvent.AddListener(Curser_OnNearCurser);
        StartPlay();
    }

    private void Curser_OnNearCurser()
    {
        leftController.DisAbleTeleProt();
        rightController.DisAbleTeleProt();
        jiaoShouJia.PlayAnimation();
        curser.SetActive(false);
    }

    private void jiaoshoujia_OnOver()
    {
        Debug.Log("OnOver");
        endTip.ShowTip(TipWords.game0_jiaoshoujiaTip);
        MyControllerManager.instance.EnableController();
    }


    /// <summary>
    /// 两种模式切换
    /// </summary>
    private void StartPlay()
    {
        if (PlayerPrefs.GetString("mode")=="教育模式")
        {
            Debug.Log("开始教育模式");
            Debug.Log("当前场景为：" + PlayerPrefs.GetString("sceneName"));
            cameraPathAni.Play();
            MyControllerManager.instance.DisableController();

        }
        else
        {
            Debug.Log("开始体验模式");
            Debug.Log("当前场景为：" + PlayerPrefs.GetString("sceneName"));

        }
    }
}
